<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增主轴监控')" />
</head>
<body>
    <form class="layui-form">
        <div class="mainBox">
            <div class="main-container">
                <div class="layui-form-item">
                    <label class="layui-form-label">型号：</label>
                    <div class="layui-input-block">
                        <select name="axisType"  style="width: 130px"  >
                            <option value="">所有</option>
                            <option value="型号1">型号1</option>
                            <option value="型号2">型号2</option>
                            <option value="型号3">型号3</option>
                            <option value="型号4">型号4</option>
                        </select>
                    </div>
                </div>
            <div class="layui-form-item">
                <label class="layui-form-label">位置：</label>
                <div class="layui-input-block">
                    <select name="axisSpace" style="width: 130px" >
                        <option value="">不限</option>
                        <option value="机房1">机房1</option>
                        <option value="机房2">机房2</option>
                        <option value="机房3">机房3</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">状态：</label>
                <div class="layui-input-block">
                    <select name="axisState"  style="width: 130px"  >
                        <option value="正常">正常</option>
                        <option value="调试">调试</option>
                        <option value="故障">故障</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">操作者：</label>
                <div class="layui-input-block">
                    <input type="text" name="currentOperator" placeholder="请输入当前操作者" class="layui-input" />
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">执行程序：</label>
                <div class="layui-input-block">
                    <input type="text" name="executiveRoutine" placeholder="请输入执行程序" class="layui-input" />
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">计划加工：</label>
                <div class="layui-input-block">
                    <input type="text" name="scheduling" placeholder="请输入计划加工" class="layui-input" />
                </div>
            </div>
            <!--<div class="layui-form-item">-->
                <!--<label class="layui-form-label">实际完成：</label>-->
                <!--<div class="layui-input-block">-->
                    <!--<input type="text" name="actuallyComplete" placeholder="请输入实际完成" class="layui-input" />-->
                <!--</div>-->
            <!--</div>-->
            <div class="layui-form-item">
                <label class="layui-form-label">售后公司：</label>
                <div class="layui-input-block">
                    <input type="text" name="manufacturer" placeholder="请输入售后公司" class="layui-input" />
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">售后公司电话：</label>
                <div class="layui-input-block">
                    <input type="text" name="manufacturerPhone" placeholder="请输入售后公司电话" class="layui-input" />
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">保修时间：</label>
                <div class="layui-input-block">
                    <input type="text" name="warrantyPeriod" placeholder="请输入保修时间" class="layui-input" />
                </div>
            </div>
            <!--<div class="layui-form-item">-->
                <!--<label class="layui-form-label">主轴对应的刀具：</label>-->
                <!--<div class="layui-input-block">-->
                    <!--<input type="text" name="axisTool" placeholder="请输入主轴对应的刀具" class="layui-input" />-->
                <!--</div>-->
            <!--</div>-->
            <!--<div class="layui-form-item">-->
                <!--<label class="layui-form-label">主轴对应的电机：</label>-->
                <!--<div class="layui-input-block">-->
                    <!--<input type="text" name="axisMotor" placeholder="请输入主轴对应的电机" class="layui-input" />-->
                <!--</div>-->
            <!--</div>-->
            </div>
        </div>
        <div class="bottom">
            <div class="button-container">
                <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit="" lay-filter="axis-save">
                    <i class="layui-icon layui-icon-ok"></i>
                    提交
                </button>
                <button type="reset" class="pear-btn pear-btn-sm">
                    <i class="layui-icon layui-icon-refresh"></i>
                    重置
                </button>
            </div>
        </div>
    </form>
</body>
<th:block th:include="include :: footer" />
<script th:inline="javascript">

    layui.use(['form', 'jquery','laydate','dictionary'], function () {
        let form = layui.form;
        let $ = layui.jquery;
        let laydate = layui.laydate;
        let prefix = "/system/axis/"
                    laydate.render({
                    elem: '#startTime'
                });
                    laydate.render({
                    elem: '#runTime'
                });
                    laydate.render({
                    elem: '#installationTime',
                    trigger: 'click',
                });
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
        form.on('submit(axis-save)', function (data) {
            for(var key in data.field){
                var type=$(data.form).find("input[name='"+key+"']").attr("type");
                if(type=="checkbox"){
                    var value="";
                    $(data.form).find("input[name='"+key+"']:checked").each(function(){
                        value+=$(this).val()+",";
                    })
                    if(value!=""){
                        value=value.substr(0,value.length-1);
                        data.field[key]=value;
                    }

                }
            }
            $.ajax({
                url: prefix+'save',
                data: JSON.stringify(data.field),
                dataType: 'json',
                contentType: 'application/json',
                type: 'post',
                success: function (result) {
                    if (result.success) {
                        layer.msg(result.msg, {icon: 1, time: 1000}, function () {
                            parent.layer.close(parent.layer.getFrameIndex(window.name));
                            parent.layui.table.reload("axis-table");
                        });
                    } else {
                        layer.msg(result.msg, {icon: 2, time: 1000});
                    }
                }
            })
            return false;
        });
    });
</script>
</html>